﻿using System.Linq;
using Adalbertus.BudgetPlanner.Domain;
using Adalbertus.BudgetPlanner.Domain.Repositories;
using NHibernate.Linq;

namespace Adalbertus.BudgetPlanner.Infrastructure.Repositories
{
    public class CashFlowTypeRepository : Repository<CashFlowType>, ICashFlowTypeRepository
    {
        public CashFlowTypeRepository(IUnitOfWork unitOfWork)
            : base(unitOfWork)
        {
        }

        public CashFlowType GetByExternalSource(ExternalSource externalSource)
        {
            CashFlowType cashFlowType = UnitOfWork.Session.Query<CashFlowType>().FirstOrDefault(c => c.ExternalSource == externalSource);
            return cashFlowType;
        }
    }
}
